package com.cat.model.dao.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.cat.model.common.model.admin.AdminModuleVO;
import com.cat.model.common.model.admin.AdminRolePermissionVO;
import com.cat.model.common.model.admin.AdminRoleVO;
import com.cat.model.common.model.admin.AdminUser;
import com.cat.model.common.model.admin.AdminUserRoleVO;
import com.cat.model.common.model.common.AccountDVO;
import com.cat.model.common.model.common.AccountVO;
import com.cat.model.common.model.common.AcntWithdrawVO;
import com.cat.model.common.model.common.AlbumModelVO;
import com.cat.model.common.model.common.AlbumVO;
import com.cat.model.common.model.common.BannerVO;
import com.cat.model.common.model.common.BasOrderVO;
import com.cat.model.common.model.common.CompanyInfoVO;
import com.cat.model.common.model.common.DressupInfoVO;
import com.cat.model.common.model.common.DressupScalePictureVO;
import com.cat.model.common.model.common.DressupStyleVO;
import com.cat.model.common.model.common.DressupZedCardVO;
import com.cat.model.common.model.common.GraphicsInfoVO;
import com.cat.model.common.model.common.GraphicsScalePictureVO;
import com.cat.model.common.model.common.GraphicsStyleVO;
import com.cat.model.common.model.common.GraphicsZedCardVO;
import com.cat.model.common.model.common.IndexRecomVO;
import com.cat.model.common.model.common.MakeupInfoVO;
import com.cat.model.common.model.common.MakeupScalePictureVO;
import com.cat.model.common.model.common.MakeupStyleVO;
import com.cat.model.common.model.common.MakeupZedCardVO;
import com.cat.model.common.model.common.ModelExperVO;
import com.cat.model.common.model.common.ModelInfoVO;
import com.cat.model.common.model.common.ModelScalePictureVO;
import com.cat.model.common.model.common.ModelStyleVO;
import com.cat.model.common.model.common.ModelZedCardVO;
import com.cat.model.common.model.common.PhotographerInfoVO;
import com.cat.model.common.model.common.PhotographerScalePictureVO;
import com.cat.model.common.model.common.PhotographerStyleVO;
import com.cat.model.common.model.common.PhotographerZedCardVO;
import com.cat.model.common.model.common.ReservationRequireVO;
import com.cat.model.common.model.common.ReservationShortlistVO;
import com.cat.model.common.model.common.ReservationVO;
import com.cat.model.common.model.common.SolutionModelVO;
import com.cat.model.common.model.common.SolutionVO;
import com.cat.model.common.model.common.UserAuthInfoVO;
import com.cat.model.common.model.common.UserFavoriteVO;
import com.cat.model.web.bean.AlbumModelBean;
import com.cat.model.web.bean.IndexRecomBean;
import com.cat.model.web.bean.ModelExtendtimeBean;
import com.cat.model.web.bean.SolutionModelBean;

/**
 * 使用注解的时候一定要将XXXMapper注册一下，跟XML配置namespace一样
 * 这里面主要到DefaultSessionFactory类中注册
 * @author Administrator
 *
 */
public interface ModelMapper {

	@Update("update bas_order set status=#{status} where id=#{id}")
	public void updateStatus(@Param("id") long id,@Param("status") String status);
	
	@Select("select * from model_info")
	public List<ModelInfoVO> getAll();

	@Select("select * from model_info where id=#{id}")
	public ModelInfoVO getModelInfo(@Param("id") long id);
	
	@Select("select * from model_info where modelCode=#{modelCode}")
	public ModelInfoVO getModelInfoByCode(@Param("modelCode") String modelCode);
	
	@Select("select * from company_info")
	public List<CompanyInfoVO> getAllCompany();

	@Select("select * from company_info where id=#{id}")
	public CompanyInfoVO getCompanyInfo(@Param("id") long id);
	
	@Select("select * from model_style where modelId=#{modelId}")
	public List<ModelStyleVO> getModelStyleList(@Param("modelId") long modelId);
	
	@Select("select * from model_exper where modelId=#{modelId}")
	public List<ModelExperVO> getModelExperList(@Param("modelId") long modelId);
	
	@Select("select * from model_scale_picture where id=#{id}")
	public ModelScalePictureVO getModelScalePic(@Param("id") long id);
	
	@Select("select * from model_scale_picture where modelId=#{modelId}")
	public List<ModelScalePictureVO> getModelScalePictureList(@Param("modelId") long modelId);
	
	@Select("select * from model_zed_card where id=#{id}")
	public ModelZedCardVO getModelZedCard(@Param("id") long id);
	
	@Select("select * from model_zed_card where modelId=#{modelId}")
	public List<ModelZedCardVO> getModelZedCardList(@Param("modelId") long modelId);
	
	@Select("select * from index_recom where id=#{id}")
	public IndexRecomVO getIndexRecom(@Param("id") long id);
	
	@Select("select * from banner where id=#{id}")
	public BannerVO getBanner(@Param("id") long id);
	
	@Select("select * from album where id=#{id}")
	public AlbumVO getAlbum(@Param("id") long id);
	
	@Select("select mo.name modelName,m.* from model m left join model_info mo on mo.id=m.modelId where m.id=#{id}")
	public AlbumModelBean getAlbumModelBean(@Param("id") long id);
	
	@Select("select * from model  where id=#{id}")
	public AlbumModelVO getAlbumModel(@Param("id") long id);
	
	@Select("select * from user_auth_info where id=#{id}")
	public UserAuthInfoVO getUserAuthInfo(@Param("id") long id);
	
	@Select("select * from acnt_withdraw where id=#{id}")
	public AcntWithdrawVO getAcntWithdraw(@Param("id") long id);
	
	@Select("select * from acnt_withdraw where userId=#{userId}")
	public List<AcntWithdrawVO> getAcntWithdrawByUserId(@Param("userId") long userId);
	
	@Select("select * from model  where albumId=#{albumId} and modelId=#{modelId} and type=#{type}")
	public AlbumModelVO getAlbumModelByType(@Param("albumId") long albumId,@Param("modelId") long modelId,@Param("type") String type);
	
	@Select("select * from reservation_require where reservationId=#{reservationId}")
	public List< ReservationRequireVO> getReservationRequire(@Param("reservationId") long reservationId);
	
	@Select("select * from reservation_shortlist where reservationId=#{reservationId}")
	public List< ReservationShortlistVO> getReservationShortlist(@Param("reservationId") long reservationId);
	
	@Select("select * from reservation where id=#{id}")
	public ReservationVO getReservation(@Param("id") long id);
	
	@Select("select * from reservation where userId=#{userId} order by id desc")
	public List<ReservationVO> getReservationList(@Param("userId") long userId);
	
	@Select("select * from bas_order where orderNumber=#{orderNumber}")
	public  BasOrderVO getBasOrderByOrderNumber(@Param("orderNumber") String orderNumber);
	
	@Select("select * from solution_model  where solutionId=#{solutionId} and modelId=#{modelId}")
	public List<SolutionModelVO> getSolutionModelByType(@Param("solutionId") long albumId,@Param("modelId") long modelId);
	
	@Select("select * from solution where reservationId=#{reservationId}")
	public SolutionVO getSolution(@Param("reservationId") long reservationId);
	
	@Select("select * from solution where id=#{id}")
	public SolutionVO getSolutionById(@Param("id") long id);
	
	@Select("select mo.name modelName,m.* from solution_model m left join model_info mo on mo.id=m.modelId where m.id=#{id}")
	public SolutionModelBean getSolutionModelBean(@Param("id") long id);
	
	@Select("select mo.name modelName,m.* from solution_model m left join model_info mo on mo.id=m.modelId where m.solutionId=#{solutionId}")
	public List<SolutionModelBean> getSolutionModelBySolutionId(@Param("solutionId") long solutionId);
	
	@Select("select * from solution_model where solutionId=#{solutionId}")
	public List< SolutionModelVO> getSolutionModel(@Param("solutionId") long solutionId);
	
	@Select("select * from admin_user_role where userId=#{userId} and roleId=#{roleId} order by id")
	public AdminUserRoleVO getAdminUserRole(@Param("userId") long userId,@Param("roleId") long roleId);
	
	@Select("select * from admin where id=#{id}")
	public AdminUser getAdminUser(@Param("id") long id);
	
	@Select("select * from admin where username=#{username}")
	public AdminUser getAdminUserByName(@Param("username") String username);
	
	@Select("select * from admin_module where id=#{id}")
	public AdminModuleVO getAdminModule(@Param("id") long id);
	
	@Select("select * from admin_module where sysCode=#{sysCode}")
	public List< AdminModuleVO> getAllAdminModuleBySysCode(@Param("sysCode") String sysCode);
	
	@Select("select * from admin_module where 1=1")
	public List< AdminModuleVO> getAllAdminModule();
	
	@Select("select * from admin_role where id=#{id}")
	public AdminRoleVO getAdminRole(@Param("id") long id);
	
	@Select("select * from admin_role_permission where roleId=#{roleId}")
	public AdminRolePermissionVO getAdminRolePermission(@Param("roleId") long roleId);
	
	@Select("select * from banner where cityCode=#{cityCode}")
	public List<BannerVO> getBannerList(@Param("cityCode") String cityCode);
	
	@Select("select mo.name modelName,mo.age,mo.sex,mo.price,mo.cityCode modelCityCode,mo.countryCode,mo.modelCode,m.* from index_recom m left join model_info mo on mo.id=m.modelId where m.cityCode=#{cityCode} order by orderIndex DESC")
	public List<IndexRecomBean> getIndexRecomList(@Param("cityCode") String cityCode);
	
	@Select("select * from user_favorite where userId=#{userId} and targetId=#{targetId} and targetType=#{targetType}")
	public UserFavoriteVO getUserFavor(@Param("userId") Long userId, @Param("targetId") Long targetId, @Param("targetType") String targetType);
	
	@Select("select * from user_favorite where id=#{id}")
	public UserFavoriteVO getUserFavorById(@Param("id") Long id);
	
	@Select("select * from user_favorite where userId=#{userId} and targetType=#{targetType} order by id desc")
	public List<UserFavoriteVO> getUserFavorList(@Param("userId") Long userId,@Param("targetType") String targetType);
	
	@Select("select count(*) from user_favorite where targetId=#{targetId} and targetType=#{targetType}")
	public int getTargetFavoriteCount(@Param("targetId") Long targetId, @Param("targetType") String targetType);
	
	@Select("select * from account where userId=#{userId}")
	public AccountVO getAccount(@Param("userId") Long userId);
	
	@Select("select * from account_d where accountId=#{accountId}  order by id")
	public List<AccountDVO> getAccountDList(@Param("accountId") Long accountId);
	
	@Select("select * from user_auth_info where userId=#{userId} limit 1")
	public UserAuthInfoVO getUserAuthInfoByUserId(@Param("userId") long userId);
	
	@Delete("delete  from user_auth_info where userId=#{userId}")
	public void deleteUserAuthInfoByUserId(@Param("userId") long userId);
	
	@Select("select * from photographer_info where id=#{id}")
	public PhotographerInfoVO getPhotographerInfo(@Param("id") long id);
	
	@Select("select * from photographer_style where photographerId=#{photographerId}")
	public List<PhotographerStyleVO> getPhotographerStyleList(@Param("photographerId") long photographerId);
	
	@Select("select * from dressup_info where id=#{id}")
	public DressupInfoVO getDressupInfo(@Param("id") long id);
	
	@Select("select * from dressup_style where dressupId=#{dressupId}")
	public List<DressupStyleVO> getDressupStyleList(@Param("dressupId") long dressupId);
	
	@Select("select * from makeup_info where id=#{id}")
	public MakeupInfoVO getMakeupInfo(@Param("id") long id);
	
	@Select("select * from makeup_style where makeupId=#{makeupId}")
	public List<MakeupStyleVO> getMakeupStyleList(@Param("makeupId") long makeupId);
	
	@Select("select * from graphics_info where id=#{id}")
	public GraphicsInfoVO getGraphicsInfo(@Param("id") long id);
	
	@Select("select * from graphics_style where graphicsId=#{graphicsId}")
	public List<GraphicsStyleVO> getGraphicsStyleList(@Param("graphicsId") long graphicsId);
	
	@Select("select mo.name modelName,m.* from model_extendtime m left join model_info mo on mo.id=m.modelId where m.refOrderNumber=#{refOrderNumber}")
	public List<ModelExtendtimeBean> getModelExtendtimeByRefOrderNo(@Param("refOrderNumber") String refOrderNumber);
	
	@Select("select mo.name modelName,m.* from model_extendtime m left join model_info mo on mo.id=m.modelId where m.orderNumber=#{orderNumber}")
	public ModelExtendtimeBean getModelExtendtimeByOrderNo(@Param("orderNumber") String orderNumber);
	
	@Select("select * from dressup_scale_picture where id=#{id}")
	public DressupScalePictureVO getDressupScalePic(@Param("id") long id);
	
	@Select("select * from dressup_scale_picture where dressupId=#{dressupId}")
	public List<DressupScalePictureVO> getDressupScalePictureList(@Param("dressupId") long dressupId);
	
	@Select("select * from dressup_zed_card where id=#{id}")
	public DressupZedCardVO getDressupZedCard(@Param("id") long id);
	
	@Select("select * from dressup_zed_card where dressupId=#{dressupId}")
	public List<DressupZedCardVO> getDressupZedCardList(@Param("dressupId") long dressupId);
	
	@Select("select * from makeup_scale_picture where id=#{id}")
	public MakeupScalePictureVO getMakeupScalePic(@Param("id") long id);
	
	@Select("select * from makeup_scale_picture where makeupId=#{makeupId}")
	public List<MakeupScalePictureVO> getMakeupScalePictureList(@Param("makeupId") long makeupId);
	
	@Select("select * from makeup_zed_card where id=#{id}")
	public MakeupZedCardVO getMakeupZedCard(@Param("id") long id);
	
	@Select("select * from makeup_zed_card where makeupId=#{makeupId}")
	public List<MakeupZedCardVO> getMakeupZedCardList(@Param("makeupId") long makeupId);
	
	@Select("select * from graphics_scale_picture where id=#{id}")
	public GraphicsScalePictureVO getGraphicsScalePic(@Param("id") long id);
	
	@Select("select * from graphics_scale_picture where graphicsId=#{graphicsId}")
	public List<GraphicsScalePictureVO> getGraphicsScalePictureList(@Param("graphicsId") long graphicsId);
	
	@Select("select * from graphics_zed_card where id=#{id}")
	public GraphicsZedCardVO getGraphicsZedCard(@Param("id") long id);
	
	@Select("select * from graphics_zed_card where graphicsId=#{graphicsId}")
	public List<GraphicsZedCardVO> getGraphicsZedCardList(@Param("graphicsId") long graphicsId);
	
	@Select("select * from photographer_scale_picture where id=#{id}")
	public PhotographerScalePictureVO getPhotographerScalePic(@Param("id") long id);
	
	@Select("select * from photographer_scale_picture where photographerId=#{photographerId}")
	public List<PhotographerScalePictureVO> getPhotographerScalePictureList(@Param("photographerId") long photographerId);
	
	@Select("select * from photographer_zed_card where id=#{id}")
	public PhotographerZedCardVO getPhotographerZedCard(@Param("id") long id);
	
	@Select("select * from photographer_zed_card where photographerId=#{photographerId}")
	public List<PhotographerZedCardVO> getPhotographerZedCardList(@Param("photographerId") long photographerId);
	
	@Select("select * from bas_order where refBizId=#{refBizId} and refBizName=#{refBizName}")
	public  BasOrderVO getBasOrderBySolutionId(@Param("refBizId") Long refBizId,@Param("refBizName") String refBizName);
	
	@Select("SELECT * from solution_model WHERE workCityCode in("+
				"SELECT name from bas_config WHERE configValue=#{configValue}"+
				") and workStartTime >  now() and status='03' group by modelId limit #{page},#{size}")
	public List<SolutionModelVO> getSolutionModelList(@Param("configValue") String configValue,
			@Param("page") Integer page,@Param("size") Integer size);
	
	@Select("select * from company_info")
	public List<CompanyInfoVO> getCompanyList();
	
}
